package org.zoomdev.zoom.web.test;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemHeaders;

import java.io.*;
import java.nio.file.Files;

public class MockFileItem implements FileItem {

    private final File file;
    private final InputStream is;

    public MockFileItem(File file) {
        this.file = file;
        this.is = null;
    }
    public MockFileItem(InputStream file) {
        this.is = file;
        this.file = null;
    }
    @Override
    public InputStream getInputStream() throws IOException {
        if(is!=null){
            return is;
        }
        return Files.newInputStream(file.toPath());
    }

    @Override
    public String getContentType() {
        return "";
    }

    @Override
    public String getName() {
        return "";
    }

    @Override
    public boolean isInMemory() {
        return false;
    }

    @Override
    public long getSize() {
        return 0;
    }

    @Override
    public byte[] get() {
        return new byte[0];
    }

    @Override
    public String getString(String s) throws UnsupportedEncodingException {
        return "";
    }

    @Override
    public String getString() {
        return "";
    }

    @Override
    public void write(File file) throws Exception {

    }

    @Override
    public void delete() {

    }

    @Override
    public String getFieldName() {
        return "";
    }

    @Override
    public void setFieldName(String s) {

    }

    @Override
    public boolean isFormField() {
        return false;
    }

    @Override
    public void setFormField(boolean b) {

    }

    @Override
    public OutputStream getOutputStream() throws IOException {
        return null;
    }

    @Override
    public FileItemHeaders getHeaders() {
        return null;
    }

    @Override
    public void setHeaders(FileItemHeaders fileItemHeaders) {

    }
}
